home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Creative Computers
/
Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso
/
shareware
/
graphics
/
screen_jaeger
/
source
/
prog.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-17
|
19KB
|
829 lines
/*************************************************************\
* SCREEN JAEGER *
* ~~~~~~ ~~~~~~ *
* *
* 'Jaeger' - German word meaning HUNTER *
* I'm not German, but I like the word *
* *
* Written by Syd L. Bolton *
* ©1991 Legendary Design Technologies Inc. *
* *
* Compiled using Manx Aztec C (tm) V5.0 *
* *
* Started: Date: May 13, 1991 Time: 18:55:00 *
* Version: 1.00 Date: July 12, 1991 Time: 00:17:00 *
* Version: 1.01 Date: July 16, 1991 Time: 12:30:00 *
\*************************************************************/
#include <intuition/intuition.h>
#include <intuition/intuitionbase.h>
#include <exec/memory.h>
#include <exec/execbase.h>
#include <graphics/gfx.h>
#include <graphics/gfxbase.h>
#include <math.h>
#include <iff.h>
long *IntuitionBase,*GfxBase,*IFFBase;
extern struct ExecBase *SysBase;
struct MemHeader *mh;
struct BitMap bm;
struct Screen *Screen,*MainScreen;
struct Window *Window,*MessageWindow,*InfoWindow;
struct ViewPort *ViewPort,*vport;
struct RastPort *rport,*mrport,*irport;
UWORD colortable[32];
long upper[2],lower[2],xbody,ybody;
long FOffset[6];
PLANEPTR PlanePtr[6];
#include "screen.h"
#include "main.h"
#include "message.h"
#include "info.h"
#define CHIP 0
#define FAST 1
int num_bitplanes=1,fine=0,direction,plane=0,copy=0,swap=0;
int width,height,NormalRows;
int type=CHIP;
int XOffset=0,YOffset=0;
int overscan=0;
long offset=32768;
main()
{
int i,exit_prog=0;
struct IntuiMessage *message;
ULONG class;
openlibraries();
setup();
show_plane(2,1);
do {
WaitPort(Window->UserPort);
while( (message = (struct IntuiMessage *)
GetMsg(Window->UserPort) ) != NULL)
{
class = message->Class;
ReplyMsg(message);
if ( class == GADGETUP) exit_prog=option(message);
if ( class == GADGETDOWN && fine==0) holdit(message);
if ( class == VANILLAKEY) key(message);
}
} while (exit_prog==0);
closestuff(0);
}
#include "pointer.h"
key(message)
struct IntuiMessage *message;
{
int c;
c=message->Code;
switch (c) {
case 'b':
case 'B': ScreenToFront(Screen);
break;
case 'f':
case 'F': ScreenToFront(MainScreen);
break;
case 'm':
case 'M': MainScreen->TopEdge=0;
MainScreen->ViewPort.DyOffset=0;
Screen->TopEdge=57;
Screen->ViewPort.DyOffset=57;
ScreenToFront(Screen);
RemakeDisplay();
break;
case 'n':
case 'N': MainScreen->TopEdge=NormalRows-56;
MainScreen->ViewPort.DyOffset=NormalRows-56;
Screen->TopEdge=0;
Screen->ViewPort.DyOffset=0;
ScreenToFront(MainScreen);
RemakeDisplay();
break;
default: break;
}
}
holdit(message)
struct IntuiMessage *message;
{
struct Gadget *igad;
int gadgid,hiexit=0;
ULONG class;
igad=(struct Gadget *) message->IAddress;
gadgid=igad->GadgetID;
if (copy==1 || swap==1) {
ClearPointer(Window);
copy=swap=0;
} /* turn off special modes */
if (overscan) return();
do {
message=(struct IntuiMessage *) GetMsg(Window->UserPort);
if (message != NULL) {
class=message->Class;
ReplyMsg(message);
if (class==GADGETUP) hiexit=1;
}
switch (gadgid) {
case 1: offset-=width;
if (offset < lower[type]) offset=lower[type];
redo();
break;
case 2: offset++;
if (offset+(width/8)*height > upper[type]) offset=upper[type]-width/8*height;
redo();
break;
case 3: offset+=width;
if (offset+(width/8)*height > upper[type]) offset=upper[type]-width/8*height;
redo();
break;
case 4: offset--;
if (offset < lower[type]) offset=lower[type];
redo();
break;
case 45: redoprop();
break;
default: break;
}
} while (hiexit==0);
}
option(message)
struct IntuiMessage *message;
{
struct Gadget *igad;
int gadgid;
long temp;
ULONG size,max;
igad=(struct Gadet *) message->IAddress;
gadgid=igad->GadgetID;
switch(gadgid) {
case 1: if (overscan) doscan(1);
else {
offset-=width/(7*fine+1);
if (offset < lower[type]) offset=lower[type];
redo();
}
break;
case 2: if (overscan) doscan(2);
else {
offset++;
if (offset+(width/8)*height > upper[type]) offset=upper[type]-width/8*height;
redo();
}
break;
case 3: if (overscan) doscan(3);
else {
offset+=width/(7*fine+1);
if (offset+(width/8)*height > upper[type]) offset=upper[type]-width/8*height;
redo();
}
break;
case 4: if (overscan) doscan(4);
else {
offset--;
if (offset < lower[type]) offset=lower[type];
redo();
}
break;
case 5: num_bitplanes++;
if (num_bitplanes > 6) num_bitplanes=6;
if (type==FAST) {
PlanePtr[num_bitplanes-1]=AllocRaster(width,height);
if (PlanePtr[num_bitplanes-1]) {
CopyMem(lower[FAST],PlanePtr[num_bitplanes-1],(width/8)*height);
bm.Planes[num_bitplanes-1]=PlanePtr[num_bitplanes-1];
Screen->RastPort.BitMap->Planes[num_bitplanes-1]=PlanePtr[num_bitplanes-1]; /* if not, couldn't allocate the chip memory */
}
else num_bitplanes--;
}
set_depth();
break;
case 6: num_bitplanes--;
if (num_bitplanes < 1) num_bitplanes=1;
if (type==FAST) {
if (PlanePtr[num_bitplanes]) FreeRaster(PlanePtr[num_bitplanes],width,height);
PlanePtr[num_bitplanes]=0;
}
set_depth();
if (plane >= num_bitplanes) {
show_plane(1,2);
plane=num_bitplanes-1;
show_plane(2,1);
}
break;
case 7: offset=atoi(Gadget32SIBuff);
if (offset < lower[type]) offset=lower[type];
if (offset+width/8*height > upper[type]) offset=upper[type]-width/8*height;
redo();
calcpropgad();
break;
case 9: if (Gadget6.Flags & SELECTED)
fine=1;
else fine=0;
break;
case 10: if (Gadget13.Flags & SELECTED) {
if (type==FAST) freefastmem();
Screen->ViewPort.Modes |= LACE;
Screen->RastPort.BitMap->Rows=NormalRows*2;
bm.Rows=NormalRows*2;
Screen->Height=NormalRows*2;
Screen->ViewPort.DHeight=NormalRows*2;
height=NormalRows*2;
if (type==FAST) allocfastmem();
}
else {
if (type==FAST) freefastmem();
Screen->ViewPort.Modes &= ~LACE;
Screen->RastPort.BitMap->Rows=NormalRows;
bm.Rows=NormalRows;
Screen->Height=NormalRows;
Screen->ViewPort.DHeight=NormalRows;
height=NormalRows;
if (type==FAST) allocfastmem();
}
calcpropgad();
fixhwgads();
RemakeDisplay();
break;
case 11: if (Gadget14.Flags & SELECTED) {
if (type==FAST) freefastmem();
Screen->ViewPort.Modes |= HIRES;
Screen->Width=640;
Screen->RastPort.BitMap->BytesPerRow=80;
bm.BytesPerRow=80; /* 640 div 8 */
Screen->ViewPort.DWidth=640;
width=640;
if (type==FAST) allocfastmem();
}
else {
if (type==FAST) freefastmem();
Screen->ViewPort.Modes &= ~HIRES;
Screen->Width=320;
bm.BytesPerRow=40; /* 320 div 8 */
Screen->RastPort.BitMap->BytesPerRow=40;
Screen->ViewPort.DWidth=320;
width=320;
if (type==FAST) allocfastmem();
}
calcpropgad();
fixhwgads();
RemakeDisplay();
break;
case 12: if (Gadget15.Flags & SELECTED) {
Screen->ViewPort.Modes |= EXTRA_HALFBRITE;
if (num_bitplanes < 6) Message("WARNING: Should have 6 bitplanes.");
}
else
Screen->ViewPort.Modes &= ~EXTRA_HALFBRITE;
RemakeDisplay();
break;
case 13: if (Gadget16.Flags & SELECTED) {
Screen->ViewPort.Modes |= HAM;
if (num_bitplanes < 6) Message("WARNING: Should have 6 bitplanes.");
}
else
Screen->ViewPort.Modes &= ~HAM;
RemakeDisplay();
break;
case 20:
case 21:
case 22:
case 23:
case 24:
case 25: if (gadgid-19 > num_bitplanes) break;
if (type==FAST) FOffset[plane]=offset;
if (copy==1) {
bm.Planes[gadgid-20]=Screen->RastPort.BitMap->Planes[gadgid-20]=bm.Planes[plane];
copy=0;
ClearPointer(Window);
RemakeDisplay();
}
if (swap==1) {
temp